import { createApp } from "vue";
import naive from "naive-ui";
import router from "@/router";
import App from "@/layouts/Provider.vue";
import * as api from "@/services";
import emitter from "@/utils/emitter";
import config from "@/config";
import * as utils from "@/utils/utils";
import { createPinia } from "pinia";
import piniaPluginPersist from "pinia-plugin-persist";

import "@/utils/ployfill.js";

//字体
// import "vfonts/Lato.css";
import "vfonts/Inter.css";
// import "vfonts/FiraCode.css";

import "./permission";

const app = createApp(App);
const store = createPinia();
store.use(piniaPluginPersist);
app.use(router);
app.use(store);
app.use(naive);

// 空数据占位
// import Empty from "@/common/Empty/index.vue";
// app.component("Empty", Empty);
// 图片展示组件
import VImage from "@/common/VImage/index.vue";
app.component("VImage", VImage);

import "@/styles/global.less";

import { setupGlobDirectives } from "@/directives";
// 注册全局指令
setupGlobDirectives(app);

//dayjs
import dayjs from "dayjs";
import "dayjs/locale/zh-cn";
dayjs.locale("zh-cn");

app.provide("global", {
    $api: api.default,
    $config: config,
    $emitter: emitter,
    $utils: utils,
    $dayjs: dayjs,
});

//animate.css
import "animate.css";

import plugins from "@/plugins"; // plugins
app.use(plugins);

//程序操作监听
app.config.errorHandler = (err) => {
    console.log("---前端程序报错---", err);
};

app.mount("#app");
